<?
ignore_user_abort(false);

require("config/config.php");
require("lib/lib.mysql.php");
require("lib/lib.common.php");
require("lib/lib.htdb.php");

$db = new db;
$db->connect($db_host, $db_user, $db_pass, $db_name);
$common = new common;
$session = new session($common,$db);

if(!$session->logged_in ||
($common->confirm_uid($_SESSION["uid"],$db)!=0))
   $common->redirect("cms_login.php");

$htdb = new htdb;

$page = $_REQUEST["Page"];
$self = $_SERVER["SCRIPT_NAME"];

while(list($key, $value) = each($HTTP_GET_VARS))
{
	if($key!="Page") {
		if(is_array($value)) {
			while(list($tmpkey, $tmpvalue) = each($value)) {
        $self .= "&" . $key . "%5B%5D=" . $tmpvalue;
      }
    } else {
      $self .= "&" . $key . "=" . $value;
    }
  }
}

$self = preg_replace("/&/si","?",$self,1);
$return = $self;

if(empty($page))
  $page = 1;

	$listings_per_page = 5;
	$members_count = $htdb->view_members_count($db);
	$pagination = new pagination($members_count, $listings_per_page, $page, $self, 5);
	$lower_limit = $pagination->calculate_lower_limit($listings_per_page,$page);
	$members_array = $htdb->view_select_members($lower_limit,$listings_per_page,$db);

ob_start();
require("templates/cms_main.htm");
$output = ob_get_contents();
ob_end_clean();

print $output;

$db->close();
?>